package net.lab1024.sa.admin.module.business.event.controller;

import net.lab1024.sa.admin.module.business.event.domain.form.EventAddForm;
import net.lab1024.sa.admin.module.business.event.domain.form.EventQueryForm;
import net.lab1024.sa.admin.module.business.event.domain.form.EventUpdateForm;
import net.lab1024.sa.admin.module.business.event.domain.vo.EventVO;
import net.lab1024.sa.admin.module.business.event.service.EventService;
import net.lab1024.sa.admin.module.business.marker.domain.vo.MarkerVO;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import cn.dev33.satoken.annotation.SaCheckPermission;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;

import java.util.List;

/**
 * 事件表 Controller
 *
 * @Author 骆伟林
 * @Date 2025-11-04 09:05:22
 * @Copyright 软件需求工程第八组
 */

@RestController
@Tag(name = "事件表")
public class EventController {

    @Resource
    private EventService eventService;

    @Operation(summary = "分页查询 @author 骆伟林")
    @PostMapping("/event/queryPage")
    @SaCheckPermission("event:query")
    public ResponseDTO<PageResult<EventVO>> queryPage(@RequestBody @Valid EventQueryForm queryForm) {
        return ResponseDTO.ok(eventService.queryPage(queryForm));
    }

    @Operation(summary = "添加 @author 骆伟林")
    @PostMapping("/event/add")
    @SaCheckPermission("event:add")
    public ResponseDTO<String> add(@RequestBody @Valid EventAddForm addForm) {
        return eventService.add(addForm);
    }

    @Operation(summary = "更新 @author 骆伟林")
    @PostMapping("/event/update")
    @SaCheckPermission("event:update")
    public ResponseDTO<String> update(@RequestBody @Valid EventUpdateForm updateForm) {
        return eventService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author 骆伟林")
    @PostMapping("/event/batchDelete")
    @SaCheckPermission("event:delete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Long> idList) {
        return eventService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author 骆伟林")
    @GetMapping("/event/delete/{eventId}")
    @SaCheckPermission("event:delete")
    public ResponseDTO<String> batchDelete(@PathVariable String eventId) {
        return eventService.delete(eventId);
    }

    @Operation(summary = "完成事件 @author 骆伟林")
    @GetMapping("/event/complete/{eventId}")
    @SaCheckPermission("event:complete")
    public ResponseDTO<String> complete(@PathVariable Long eventId) {
        return eventService.finish(eventId);
    }

    @Operation(summary = "撤销完成事件 @author 骆伟林")
    @GetMapping("/event/revokeComplete/{eventId}")
    @SaCheckPermission("event:revokeComplete")
    public ResponseDTO<String> revokeComplete(@PathVariable Long eventId) {
        return eventService.revokeFinish(eventId);
    }

    @Operation(summary = "根据地址id获取详情 @author 骆伟林")
    @GetMapping("/event/getEventListByAddressId/{addressId}")
    @SaCheckPermission("event:getEventListByAddressId")
    public ResponseDTO<List<EventVO>> getEventListByAddressId(@PathVariable Long addressId) {
        return ResponseDTO.ok(eventService.getEventListByAddressId(addressId));
    }

    @Operation(summary = "根据事件id获取详情 @author 骆伟林")
    @GetMapping("/event/getEventById/{eventId}")
    @SaCheckPermission("event:getEventById")
    public ResponseDTO<EventVO> getEventById(@PathVariable Long eventId) {
        return ResponseDTO.ok(eventService.getEventById(eventId));
    }


}
